/**
 * 
 */
package dt.inlee.system.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import dt.inlee.common.dao.impl.BaseDao;
import dt.inlee.common.exception.FrameworkException;
import dt.inlee.common.util.BaseUtil;
import dt.inlee.domain.JobDetails;

/**
 * 功能说明：
 * @作者： cnoot
 * 创建日期： 2010-5-24
 */
@Repository("jobDetailDao")
public class JobDetailsDao extends BaseDao {

	/**
	 * 判断定时任务名称是否重复
	 * @param id
	 * @param jobName
	 * @return
	 * @throws FrameworkException
	 */
	@SuppressWarnings("unchecked")
	public boolean judgeJobName(String id, String jobName) throws FrameworkException {
		Criteria criteria = hibernateTemplate.getSessionFactory().getCurrentSession().createCriteria(JobDetails.class);
		if (!BaseUtil.isEmpty(jobName))
			criteria.add(Restrictions.eq("jobName", jobName));
		if (!BaseUtil.isEmpty(id))
			criteria.add(Restrictions.ne("id", id));

		List<JobDetails> details = criteria.list();
		if (BaseUtil.isEmpty(details) || details.size() == 0) {
			return true;
		}
		return false;
	}

}
